import {Tools} from "weaver-mobile";

const GLOBAL_API = "/api/prj/moblie";
const ajaxGet = (url = "", params = {}, OwnAPI = false) => {
    const URL = OwnAPI ? url : GLOBAL_API + url;
    const options = {
        method: "GET",
        url: URL,
        params: {
            ...params,
            ismobile: 1
        }
    };
    return Tools.callApi(options);
};
const getPortalCount = params => ajaxGet("/prjportal/getPortalCount", params);//首页统计
const getApprovalTaskList = params => ajaxGet("/prjportal/getApprovalTaskList", params);//任务审批
const getExchangeList = params => ajaxGet("/prjportal/getExchangeList", params);//相关交流
const getPrjCountChart = params => ajaxGet("/prjportal/getPrjCountChart", params);//统计

const getProjectList = params => ajaxGet("/project/getProjectList", params);//项目列表
const getProjectForm = params => ajaxGet("/project/getProjectForm", params);//项目卡片查看
const getPrjTaskList = params => ajaxGet("/project/getPrjTaskList", params);//项目卡片的任务列表

const getTaskList = params => ajaxGet("/task/getTaskList", params);//任务列表
const getTaskForm = params => ajaxGet("/task/getTaskForm", params);//任务卡片查看

const getTaskExchange = params => ajaxGet("/task/getTaskExchange", params);//任务相关交流
const getPrjExchange = params => ajaxGet("/project/getPrjExchange", params);//项目相关交流
const getPrjGantt = params => ajaxGet("/project/getPrjGantt", params);//甘特图

const getTaskReferenceList = params => ajaxGet("/task/getTaskReferenceList", params);//任务相关流程、文档
const getPrjReferenceDoc = params => ajaxGet("/project/getPrjReferenceDoc", params);//流程相关文档
const getPrjStageList = params => ajaxGet("/project/getPrjStageList", params);//项目阶段

// const getProjectStastics = params => ajaxGet("/project/getProjectStastics", params);//项目统计
const doProjectOperation = params => ajaxGet("/project/doProjectOperation", params);//项目卡片保存
const doPrjPlanOperation = params => ajaxGet("/project/doPrjPlanOperation", params);//项目状态修改

const doExchangeOperation = params => ajaxGet("/prjportal/doExchangeOperation", params);//相关交流保存
const getPrjStageForm = params => ajaxGet("/project/getPrjStageForm", params);//阶段编辑
const doPrjStageOperation = params => ajaxGet("/project/doPrjStageOperation", params);//阶段编辑保存
const doTaskOperation = params => ajaxGet("/task/doTaskOperation", params);//新建、编辑、删除任务
const doTaskReference = params => ajaxGet("/task/doTaskReference", params);//文档和流程操作
const doTaskApproval = params => ajaxGet("/task/doTaskApproval", params);//任务审批和退回
const getDateByWorkLongCmd = params => ajaxGet("/prjportal/getDateByWorkLongCmd", params);//计算工期
/*----------------------*/
const fileUpload = params => ajaxGet(`/api/proj/prjutil/fileUpload`,params,true);//附件上传

module.exports = {
    getPortalCount,
    getApprovalTaskList,
    getExchangeList,
    getProjectList,
    getPrjCountChart,
    getProjectForm,
    getTaskList,
    getTaskForm,
    getPrjTaskList,
    getTaskExchange,
    getPrjExchange,
    getPrjGantt,
    getTaskReferenceList,
    getPrjReferenceDoc,
    getPrjStageList,
    // getProjectStastics,
    doProjectOperation,
    doPrjPlanOperation,
    doExchangeOperation,
    getPrjStageForm,
    doPrjStageOperation,
    doTaskOperation,
    doTaskReference,
    doTaskApproval,
    getDateByWorkLongCmd,
    fileUpload,
};
